<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>module AboutYou::SDK::QueryBuilder - RDoc Documentation</title>

<link href="../../fonts.css" rel="stylesheet">
<link href="../../rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
</script>

<script src="../../js/jquery.js"></script>
<script src="../../js/navigation.js"></script>
<script src="../../js/search_index.js"></script>
<script src="../../js/search.js"></script>
<script src="../../js/searcher.js"></script>
<script src="../../js/darkfish.js"></script>


<body id="top" role="document" class="module">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="class-metadata">
    
    
    
    
    <!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    
    <li ><a href="#method-i-add_items_to_basket">#add_items_to_basket</a>
    
    <li ><a href="#method-i-add_itemsets_to_basket">#add_itemsets_to_basket</a>
    
    <li ><a href="#method-i-add_to_basket">#add_to_basket</a>
    
    <li ><a href="#method-i-check_session_id">#check_session_id</a>
    
    <li ><a href="#method-i-fetch_autocomplete">#fetch_autocomplete</a>
    
    <li ><a href="#method-i-fetch_basket">#fetch_basket</a>
    
    <li ><a href="#method-i-fetch_categories_by_ids">#fetch_categories_by_ids</a>
    
    <li ><a href="#method-i-fetch_category_tree">#fetch_category_tree</a>
    
    <li ><a href="#method-i-fetch_child_apps">#fetch_child_apps</a>
    
    <li ><a href="#method-i-fetch_facet">#fetch_facet</a>
    
    <li ><a href="#method-i-fetch_facet_types">#fetch_facet_types</a>
    
    <li ><a href="#method-i-fetch_facets">#fetch_facets</a>
    
    <li ><a href="#method-i-fetch_live_variant_by_ids">#fetch_live_variant_by_ids</a>
    
    <li ><a href="#method-i-fetch_order">#fetch_order</a>
    
    <li ><a href="#method-i-fetch_product_search">#fetch_product_search</a>
    
    <li ><a href="#method-i-fetch_products_by_eans">#fetch_products_by_eans</a>
    
    <li ><a href="#method-i-fetch_products_by_ids">#fetch_products_by_ids</a>
    
    <li ><a href="#method-i-fetch_spell_correction">#fetch_spell_correction</a>
    
    <li ><a href="#method-i-fetch_suggest">#fetch_suggest</a>
    
    <li ><a href="#method-i-initiate_order">#initiate_order</a>
    
    <li ><a href="#method-i-query_string">#query_string</a>
    
    <li ><a href="#method-i-remove_from_basket">#remove_from_basket</a>
    
    <li ><a href="#method-i-update_basket">#update_basket</a>
    
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-labelledby="module-AboutYou::SDK::QueryBuilder">
  <h1 id="module-AboutYou::SDK::QueryBuilder" class="module">
    module AboutYou::SDK::QueryBuilder
  </h1>

  <section class="description">
    
<p>the <a href="QueryBuilder.html">QueryBuilder</a> is a module supporting the
query with mroe complex logic concerning the building of the queries for
the api-call</p>
<dl class="rdoc-list note-list"><dt>Author
<dd>
<p>Collins GmbH &amp; Co KG</p>
</dd></dl>

  </section>

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Instance Methods</h3>
       </header>

    
      <div id="method-i-add_items_to_basket" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">add_items_to_basket</span><span
            class="method-args">(session_id, items)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the basket-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; a String containing the session id of an user</p>
</li><li>
<p><code>items</code> -&gt; an Array containing all of the items which should
be added</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="add_items_to_basket-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 79</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_items_to_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">items</span>)
  <span class="ruby-identifier">check_session_id</span>(<span class="ruby-identifier">session_id</span>)

  <span class="ruby-identifier">order_lines</span> = []

  <span class="ruby-identifier">items</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">order_line</span> = {
      <span class="ruby-string">'id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">id</span>,
      <span class="ruby-string">'variant_id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">variant_id</span>
    }

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">additional_data</span>
      <span class="ruby-identifier">order_line</span>[<span class="ruby-string">'additional_data'</span>] = <span class="ruby-identifier">item</span>.<span class="ruby-identifier">additional_data</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">order_lines</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">order_line</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'basket'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'session_id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">session_id</span>,
      <span class="ruby-string">'order_lines'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">order_lines</span>
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-add_itemsets_to_basket" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">add_itemsets_to_basket</span><span
            class="method-args">(session_id, itemsets)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the basket-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; a String containing the session id of an user</p>
</li><li>
<p><code>itemSets</code> -&gt; an instance of <a
href="Model/BasketSet.html">AboutYou::SDK::Model::BasketSet</a></p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="add_itemsets_to_basket-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 117</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_itemsets_to_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">itemsets</span>)
  <span class="ruby-identifier">check_session_id</span>(<span class="ruby-identifier">session_id</span>)

  <span class="ruby-identifier">order_lines</span> = []

  <span class="ruby-identifier">itemsets</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item_set</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">order_line</span> = {
      <span class="ruby-string">'id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">item_set</span>.<span class="ruby-identifier">id</span>,
      <span class="ruby-string">'set_items'</span> =<span class="ruby-operator">&gt;</span> []
    }

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">item_set</span>.<span class="ruby-identifier">additional_data</span>
      <span class="ruby-identifier">order_line</span>[<span class="ruby-string">'additional_data'</span>] = <span class="ruby-identifier">item_set</span>.<span class="ruby-identifier">additional_data</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">item_set</span>.<span class="ruby-identifier">items</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">entry</span> = {
        <span class="ruby-string">'variant_id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">variant_id</span>
      }
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">additional_data</span>
        <span class="ruby-identifier">entry</span>[<span class="ruby-string">'additional_data'</span>] = <span class="ruby-identifier">item</span>.<span class="ruby-identifier">additional_data</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">order_line</span>[<span class="ruby-string">'set_items'</span>].<span class="ruby-identifier">push</span>(<span class="ruby-identifier">entry</span>)
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">order_lines</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">order_line</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'basket'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'session_id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">session_id</span>,
      <span class="ruby-string">'order_lines'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">order_lines</span>
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-add_to_basket" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">add_to_basket</span><span
            class="method-args">(session_id, product_variant_id, basket_item_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the basket-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; a String containing the session id of an user</p>
</li><li>
<p><code>productVariantId</code> -&gt; ID of product variant</p>
</li><li>
<p><code>basketItemId</code> -&gt; ID of single item or set in the basket</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="add_to_basket-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 166</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_to_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">product_variant_id</span>, <span class="ruby-identifier">basket_item_id</span>)
  <span class="ruby-identifier">check_session_id</span>(<span class="ruby-identifier">session_id</span>)

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'basket'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'session_id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">session_id</span>,
      <span class="ruby-string">'order_lines'</span> =<span class="ruby-operator">&gt;</span> [{
        <span class="ruby-string">'id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">basket_item_id</span>,
        <span class="ruby-string">'variant_id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Integer</span>(<span class="ruby-identifier">product_variant_id</span>)
      }]
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-check_session_id" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">check_session_id</span><span
            class="method-args">(session_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>checks whether the session id is valid or not</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; the session id of a user</p>
</li></ul>
</li><li>
<p><strong>Fails</strong> :</p>
<ul><li>
<p>if the session id is not a String</p>
</li><li>
<p>if the session id has less then 4 characters</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="check_session_id-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 569</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">check_session_id</span>(<span class="ruby-identifier">session_id</span>)
  <span class="ruby-identifier">fail</span> <span class="ruby-string">'InvalidArgumentException! The session id must be a string'</span> <span class="ruby-keyword">unless</span>
  <span class="ruby-identifier">session_id</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
  <span class="ruby-identifier">fail</span> <span class="ruby-string">'InvalidArgumentException! The session id must have at least
    5 characters'</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">session_id</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">4</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_autocomplete" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_autocomplete</span><span
            class="method-args">(searchword, limit = nil, types = nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the autocompletion-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>searchword</code> -&gt; a String containing the word to search
completitions for</p>
</li><li>
<p><code>limit</code> -&gt; Maximum number of results [optional]</p>
</li><li>
<p><code>types</code> -&gt; Array of types to search for [optional]</p>
</li></ul>
</li><li>
<p><strong>Fails</strong> :</p>
<ul><li>
<p>if the searchword is not a String</p>
</li><li>
<p>if the limit cant be transformed into an integer</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_autocomplete-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 25</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_autocomplete</span>(<span class="ruby-identifier">searchword</span>, <span class="ruby-identifier">limit</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">types</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">searchword</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
    <span class="ruby-identifier">fail</span> <span class="ruby-string">'InvalidArgumentException! searchword must be a string'</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># downcase is a workaround of ticket SAPI-532</span>
  <span class="ruby-identifier">options</span> = { <span class="ruby-string">'searchword'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">searchword</span>.<span class="ruby-identifier">downcase</span> }

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">limit</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">fail</span> <span class="ruby-string">'InvalidArgumentException! limit must be an integer'</span> <span class="ruby-keyword">unless</span>
    <span class="ruby-identifier">limit</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Integer</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">limit</span>[<span class="ruby-regexp">/\d/</span>]
    <span class="ruby-identifier">options</span>[<span class="ruby-string">'limit'</span>] = <span class="ruby-constant">Integer</span>(<span class="ruby-identifier">limit</span>)
  <span class="ruby-keyword">end</span>
  
  <span class="ruby-identifier">options</span>[<span class="ruby-string">'types'</span>] = <span class="ruby-identifier">types</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">types</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'autocompletion'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">options</span>
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_basket" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_basket</span><span
            class="method-args">(session_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the basket-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; a String containing the session id of an user</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_basket-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 57</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_basket</span>(<span class="ruby-identifier">session_id</span>)
  <span class="ruby-identifier">check_session_id</span>(<span class="ruby-identifier">session_id</span>)

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'basket'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'session_id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">session_id</span>
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_categories_by_ids" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_categories_by_ids</span><span
            class="method-args">(ids = nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the category-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>ids</code> -&gt; either a single category ID as integer or an array
of IDs</p>
</li></ul>
</li><li>
<p><strong>Fails</strong> :</p>
<ul><li>
<p>if a category id is smaller then 1</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_categories_by_ids-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 249</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_categories_by_ids</span>(<span class="ruby-identifier">ids</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
      <span class="ruby-string">'category'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">nil</span>
    )
  <span class="ruby-keyword">else</span>
    <span class="ruby-comment"># we allow to pass a single ID instead of an array</span>
    <span class="ruby-identifier">ids</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">ids</span>)

    <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">id</span> = <span class="ruby-constant">Integer</span>(<span class="ruby-identifier">id</span>)
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">id</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">1</span>
        <span class="ruby-identifier">fail</span> <span class="ruby-string">'InvalidArgumentException! A single category ID must be greater than 0'</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">ids</span> = <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span> <span class="ruby-constant">Integer</span>(<span class="ruby-identifier">id</span>) }

    <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
      <span class="ruby-string">'category'</span> =<span class="ruby-operator">&gt;</span> {
        <span class="ruby-string">'ids'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ids</span>
      }
    )
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_category_tree" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_category_tree</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the category_tree-query</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_category_tree-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 283</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_category_tree</span>
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'category_tree'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'version'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'2'</span>
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_child_apps" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_child_apps</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the child_apps-query</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_child_apps-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 541</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_child_apps</span>
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'child_apps'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">nil</span>
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_facet" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_facet</span><span
            class="method-args">(params)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the facet-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>params</code> -&gt; Hash containing 2 keys: "id", "group_id"</p>
</li></ul>
</li><li>
<p><strong>Fails</strong> :</p>
<ul><li>
<p>if params is not set</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_facet-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 461</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_facet</span>(<span class="ruby-identifier">params</span>)
  <span class="ruby-identifier">fail</span> <span class="ruby-string">'InvalidArgumentException! no params given'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'facet'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">params</span>
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_facet_types" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_facet_types</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the facet_types-query</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_facet_types-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 477</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_facet_types</span>
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'facet_types'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">nil</span>
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_facets" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_facets</span><span
            class="method-args">(group_ids = [])</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the facets-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>group_ids</code> -&gt; Array of group ids [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_facets-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 437</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_facets</span>(<span class="ruby-identifier">group_ids</span> = [])
  <span class="ruby-identifier">group_ids</span> = <span class="ruby-identifier">group_ids</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">groupId</span><span class="ruby-operator">|</span> <span class="ruby-constant">Integer</span>(<span class="ruby-identifier">groupId</span>) } <span class="ruby-keyword">if</span> <span class="ruby-identifier">group_ids</span>

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'facets'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'group_ids'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">group_ids</span>
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_live_variant_by_ids" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_live_variant_by_ids</span><span
            class="method-args">(ids)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the live_variant-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>ids</code> -&gt; Either a single id or an Array of ids which should
be fetched</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_live_variant_by_ids-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 325</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_live_variant_by_ids</span>(<span class="ruby-identifier">ids</span>)
  <span class="ruby-comment"># we allow to pass a single ID instead of an array</span>
  <span class="ruby-identifier">ids</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">ids</span>)
  <span class="ruby-identifier">ids</span> = <span class="ruby-identifier">ids</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span> <span class="ruby-constant">Integer</span>(<span class="ruby-identifier">id</span>) }

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'live_variant'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'ids'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ids</span>
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_order" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_order</span><span
            class="method-args">(order_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the get_order-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>orderId</code> -&gt; id of the order which should be fetched</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_order-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 370</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_order</span>(<span class="ruby-identifier">order_id</span>)
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'get_order'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'order_id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">order_id</span>
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_product_search" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_product_search</span><span
            class="method-args">(criteria)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the product_search-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>criteria</code> -&gt; Hash containing one or multiple search terms</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_product_search-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 418</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_product_search</span>(<span class="ruby-identifier">criteria</span>)
  <span class="ruby-identifier">check_session_id</span>(<span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">session_id</span>)

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'product_search'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">criteria</span>.<span class="ruby-identifier">to_array</span>
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_products_by_eans" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_products_by_eans</span><span
            class="method-args">(eans, fields = [])</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the products_eans-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>eans</code> -&gt; Either a single ean or an Array of eans which
should be fetched</p>
</li><li>
<p><code>fields</code> -&gt; Additional product fields which should be fetched
for each product [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_products_by_eans-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 349</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_products_by_eans</span>(<span class="ruby-identifier">eans</span>, <span class="ruby-identifier">fields</span> = [])
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'products_eans'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'eans'</span>   =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">eans</span>,
      <span class="ruby-string">'fields'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Criteria</span><span class="ruby-operator">::</span><span class="ruby-constant">ProductFields</span>.<span class="ruby-identifier">filter_fields</span>(<span class="ruby-identifier">fields</span>),
      <span class="ruby-string">'version'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'2'</span>
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_products_by_ids" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_products_by_ids</span><span
            class="method-args">(ids, fields = [])</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the products-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>ids</code> -&gt; Either a single id or an Array of ids which should
be fetched</p>
</li><li>
<p><code>fields</code> -&gt; Additional product fields which should be fetched
for each product [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_products_by_ids-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 303</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_products_by_ids</span>(<span class="ruby-identifier">ids</span>, <span class="ruby-identifier">fields</span> = [])
  <span class="ruby-comment"># we allow to pass a single ID instead of an array</span>
  <span class="ruby-identifier">ids</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">ids</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span> <span class="ruby-constant">Integer</span>(<span class="ruby-identifier">id</span>) }

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'products'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'ids'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ids</span>,
      <span class="ruby-string">'fields'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Criteria</span><span class="ruby-operator">::</span><span class="ruby-constant">ProductFields</span>.<span class="ruby-identifier">filter_fields</span>(<span class="ruby-identifier">fields</span>)
    }
  )
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_spell_correction" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_spell_correction</span><span
            class="method-args">(searchword, category_ids = nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the spell_correction</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>searchword</code> -&gt; the search string to search for</p>
</li><li>
<p><code>category_ids</code> -&gt; the cat ids to filter for</p>
</li></ul>
</li><li>
<p><strong>Fails</strong> :</p>
<ul><li>
<p>if the searchword is not a String</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_spell_correction-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 517</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_spell_correction</span>(<span class="ruby-identifier">searchword</span>, <span class="ruby-identifier">category_ids</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">fail</span> <span class="ruby-string">'InvalidArgumentException! searchword must be a string'</span> <span class="ruby-keyword">unless</span>
  <span class="ruby-identifier">searchword</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)

  <span class="ruby-identifier">options</span> = {
      <span class="ruby-string">'searchword'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">searchword</span>
  }
  <span class="ruby-identifier">options</span>[<span class="ruby-string">'filter'</span>] = {
      <span class="ruby-string">'categories'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">category_ids</span>
  } <span class="ruby-keyword">unless</span> <span class="ruby-identifier">category_ids</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
      <span class="ruby-string">'did_you_mean'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">options</span>
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-fetch_suggest" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">fetch_suggest</span><span
            class="method-args">(searchword)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the suggest-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>searchword</code> -&gt; the searchs tring to search for</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="fetch_suggest-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 494</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_suggest</span>(<span class="ruby-identifier">searchword</span>)
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'suggest'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'searchword'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">searchword</span>
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-initiate_order" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">initiate_order</span><span
            class="method-args">(session_id, success_url, cancel_url, error_url)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the initiate_order-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; A String containing the sessionId of the User</p>
</li><li>
<p><code>successUrl</code> -&gt; callback URL if the order was OK</p>
</li><li>
<p><code>cancelUrl</code> -&gt; callback URL if the order was canceled
[optional]</p>
</li><li>
<p><code>errorUrl</code> -&gt; callback URL if the order had any exceptions
[optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="initiate_order-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 392</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initiate_order</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">success_url</span>, <span class="ruby-identifier">cancel_url</span>, <span class="ruby-identifier">error_url</span>)
  <span class="ruby-identifier">check_session_id</span>(<span class="ruby-identifier">session_id</span>)

  <span class="ruby-identifier">args</span> = {
    <span class="ruby-string">'session_id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">session_id</span>,
    <span class="ruby-string">'success_url'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">success_url</span>
  }
  <span class="ruby-identifier">args</span>[<span class="ruby-string">'cancel_url'</span>] = <span class="ruby-identifier">cancel_url</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">cancel_url</span>
  <span class="ruby-identifier">args</span>[<span class="ruby-string">'error_url'</span>] = <span class="ruby-identifier">error_url</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">error_url</span>

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'initiate_order'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-query_string" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">query_string</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>turns all queries built in here into a json string</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Json string containing all queries built in here</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="query_string-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 555</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">query_string</span>
  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_json</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-remove_from_basket" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">remove_from_basket</span><span
            class="method-args">(session_id, item_ids)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the basket-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; a String containing the session id of an user</p>
</li><li>
<p><code>itemIds</code> -&gt; array of basket item ids to delete, this can be
sets or single items</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="remove_from_basket-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 192</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">remove_from_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">item_ids</span>)
  <span class="ruby-identifier">check_session_id</span>(<span class="ruby-identifier">session_id</span>)

  <span class="ruby-identifier">order_lines</span> = []

  <span class="ruby-identifier">item_ids</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">order_lines</span>.<span class="ruby-identifier">push</span>(
      <span class="ruby-string">'delete'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">id</span>
    )
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'basket'</span> =<span class="ruby-operator">&gt;</span> {
      <span class="ruby-string">'session_id'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">session_id</span>,
      <span class="ruby-string">'order_lines'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">order_lines</span>
    }
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-update_basket" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">update_basket</span><span
            class="method-args">(session_id, basket)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>builds the basket-query</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>session_id</code> -&gt; a String containing the session id of an user</p>
</li><li>
<p><code>basket</code> -&gt; an instance of <a
href="Model/Basket.html">AboutYou::SDK::Model::Basket</a></p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Query.html">AboutYou::SDK::Query</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="update_basket-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/query_builder.rb, line 223</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">update_basket</span>(<span class="ruby-identifier">session_id</span>, <span class="ruby-identifier">basket</span>)
  <span class="ruby-identifier">check_session_id</span>(<span class="ruby-identifier">session_id</span>)

  <span class="ruby-identifier">order_lines</span> = <span class="ruby-identifier">basket</span>.<span class="ruby-identifier">order_lines_array</span>
  <span class="ruby-identifier">basket_query</span> = { <span class="ruby-string">'session_id'</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">session_id</span> }
  <span class="ruby-identifier">basket_query</span>[<span class="ruby-string">'order_lines'</span>] = <span class="ruby-identifier">order_lines</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">order_lines</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">query</span>.<span class="ruby-identifier">push</span>(
    <span class="ruby-string">'basket'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">basket_query</span>
  )

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
  </section>
</main>


<footer id="validator-badges" role="contentinfo">
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.2.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>

